//
//  BBNavigationController.swift
//  BusinessBao
//
//  Created by Chen on 2017/7/16.
//  Copyright © 2017年 Chen. All rights reserved.
//

import UIKit

class BBNavigationController: UINavigationController, UINavigationControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.setupUI()
        self.delegate = self
    }
    
    /// 状态栏样式
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    
    func setupUI() {
//        let gradientLayer = CAGradientLayer()
//        gradientLayer.frame = CGRect(x: 0, y: -20, width: self.navigationBar.width, height: 64)
//        //设置渐变的主颜色
//        gradientLayer.colors = [UIColor.HexColor(hex: "0x00A8FE").cgColor, Nav_BG_Color.cgColor]
//        //渲染的起始位置
//        gradientLayer.startPoint = CGPoint(x: 0, y: 0)
//        //渲染的终止位置
//        gradientLayer.endPoint = CGPoint(x: 1, y: 0)
//        //将gradientLayer作为子layer添加到主layer上
//        self.navigationBar.layer.addSublayer(gradientLayer)
        
        self.navigationBar.tintColor = UIColor.white
        
        self.navigationBar.setBackgroundImage(UIImage(color: Nav_BG_Color, size:CGSize(width: ScreenWidth, height: 64)), for: .default)
        
        self.navigationBar.shadowImage = UIImage()
        
        self.navigationBar.titleTextAttributes = [ NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName : BoldFont(font: 18)]
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if (self.viewControllers.count == 1) {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }

}
